package org.gap.domain;

import java.io.Serializable;

import java.lang.StringBuilder;

import java.util.Calendar;
import java.util.Set;

import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;

import javax.xml.bind.annotation.*;

import javax.persistence.*;

/**
 */
@IdClass(org.gap.domain.RolesTiersPK.class)
@Entity
@NamedQueries({
		@NamedQuery(name = "findAllRolesTierss", query = "select myRolesTiers from RolesTiers myRolesTiers"),
		@NamedQuery(name = "findRolesTiersByPrimaryKey", query = "select myRolesTiers from RolesTiers myRolesTiers where myRolesTiers.rotRole = ?1 and myRolesTiers.rotTiers = ?2"),
		@NamedQuery(name = "findRolesTiersByRotDateDebut", query = "select myRolesTiers from RolesTiers myRolesTiers where myRolesTiers.rotDateDebut = ?1"),
		@NamedQuery(name = "findRolesTiersByRotDateDebutAfter", query = "select myRolesTiers from RolesTiers myRolesTiers where myRolesTiers.rotDateDebut > ?1"),
		@NamedQuery(name = "findRolesTiersByRotDateDebutBefore", query = "select myRolesTiers from RolesTiers myRolesTiers where myRolesTiers.rotDateDebut < ?1"),
		@NamedQuery(name = "findRolesTiersByRotDateFin", query = "select myRolesTiers from RolesTiers myRolesTiers where myRolesTiers.rotDateFin = ?1"),
		@NamedQuery(name = "findRolesTiersByRotDateFinAfter", query = "select myRolesTiers from RolesTiers myRolesTiers where myRolesTiers.rotDateFin > ?1"),
		@NamedQuery(name = "findRolesTiersByRotDateFinBefore", query = "select myRolesTiers from RolesTiers myRolesTiers where myRolesTiers.rotDateFin < ?1"),
		@NamedQuery(name = "findRolesTiersByRotDescriptif", query = "select myRolesTiers from RolesTiers myRolesTiers where myRolesTiers.rotDescriptif = ?1"),
		@NamedQuery(name = "findRolesTiersByRotDescriptifContaining", query = "select myRolesTiers from RolesTiers myRolesTiers where myRolesTiers.rotDescriptif like ?1"),
		@NamedQuery(name = "findRolesTiersByRotRole", query = "select myRolesTiers from RolesTiers myRolesTiers where myRolesTiers.rotRole = ?1"),
		@NamedQuery(name = "findRolesTiersByRotRoleContaining", query = "select myRolesTiers from RolesTiers myRolesTiers where myRolesTiers.rotRole like ?1"),
		@NamedQuery(name = "findRolesTiersByRotTiers", query = "select myRolesTiers from RolesTiers myRolesTiers where myRolesTiers.rotTiers = ?1") })
@Table(schema = "GAP", name = "ROLES_TIERS")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(namespace = "GAP_v2/org/gap/domain", name = "RolesTiers")
public class RolesTiers implements Serializable {
	private static final long serialVersionUID = 1L;

	/**
	 */

	@Column(name = "ROT_ROLE", length = 3, nullable = false)
	@Basic(fetch = FetchType.EAGER)
	@Id
	@XmlElement
	String rotRole;
	/**
	 */

	@Column(name = "ROT_TIERS", nullable = false)
	@Basic(fetch = FetchType.EAGER)
	@Id
	@XmlElement
	Integer rotTiers;
	/**
	 */

	@Column(name = "ROT_DESCRIPTIF", length = 100)
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	String rotDescriptif;
	/**
	 */
	@Temporal(TemporalType.DATE)
	@Column(name = "ROT_DATE_DEBUT")
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	Calendar rotDateDebut;
	/**
	 */
	@Temporal(TemporalType.DATE)
	@Column(name = "ROT_DATE_FIN")
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	Calendar rotDateFin;

	/**
	 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumns({ @JoinColumn(name = "ROT_TIERS", referencedColumnName = "TIE_TIERS", nullable = false, insertable = false, updatable = false) })
	@XmlTransient
	Tiers tiers;
	/**
	 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumns({ @JoinColumn(name = "ROT_ROLE", referencedColumnName = "ROL_ROLE", nullable = false, insertable = false, updatable = false) })
	@XmlTransient
	Roles roles;

	/**
	 */
	public void setRotRole(String rotRole) {
		this.rotRole = rotRole;
	}

	/**
	 */
	public String getRotRole() {
		return this.rotRole;
	}

	/**
	 */
	public void setRotTiers(Integer rotTiers) {
		this.rotTiers = rotTiers;
	}

	/**
	 */
	public Integer getRotTiers() {
		return this.rotTiers;
	}

	/**
	 */
	public void setRotDescriptif(String rotDescriptif) {
		this.rotDescriptif = rotDescriptif;
	}

	/**
	 */
	public String getRotDescriptif() {
		return this.rotDescriptif;
	}

	/**
	 */
	public void setRotDateDebut(Calendar rotDateDebut) {
		this.rotDateDebut = rotDateDebut;
	}

	/**
	 */
	public Calendar getRotDateDebut() {
		return this.rotDateDebut;
	}

	/**
	 */
	public void setRotDateFin(Calendar rotDateFin) {
		this.rotDateFin = rotDateFin;
	}

	/**
	 */
	public Calendar getRotDateFin() {
		return this.rotDateFin;
	}

	/**
	 */
	public void setTiers(Tiers tiers) {
		this.tiers = tiers;
	}

	/**
	 */
	public Tiers getTiers() {
		return tiers;
	}

	/**
	 */
	public void setRoles(Roles roles) {
		this.roles = roles;
	}

	/**
	 */
	public Roles getRoles() {
		return roles;
	}

	/**
	 */
	public RolesTiers() {
	}

	/**
	 * Copies the contents of the specified bean into this bean.
	 *
	 */
	public void copy(RolesTiers that) {
		setRotRole(that.getRotRole());
		setRotTiers(that.getRotTiers());
		setRotDescriptif(that.getRotDescriptif());
		setRotDateDebut(that.getRotDateDebut());
		setRotDateFin(that.getRotDateFin());
		setTiers(that.getTiers());
		setRoles(that.getRoles());
	}

	/**
	 * Returns a textual representation of a bean.
	 *
	 */
	public String toString() {

		StringBuilder buffer = new StringBuilder();

		buffer.append("rotRole=[").append(rotRole).append("] ");
		buffer.append("rotTiers=[").append(rotTiers).append("] ");
		buffer.append("rotDescriptif=[").append(rotDescriptif).append("] ");
		buffer.append("rotDateDebut=[").append(rotDateDebut).append("] ");
		buffer.append("rotDateFin=[").append(rotDateFin).append("] ");

		return buffer.toString();
	}

	/**
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = (int) (prime * result + ((rotRole == null) ? 0 : rotRole.hashCode()));
		result = (int) (prime * result + ((rotTiers == null) ? 0 : rotTiers.hashCode()));
		return result;
	}

	/**
	 */
	public boolean equals(Object obj) {
		if (obj == this)
			return true;
		if (!(obj instanceof RolesTiers))
			return false;
		RolesTiers equalCheck = (RolesTiers) obj;
		if ((rotRole == null && equalCheck.rotRole != null) || (rotRole != null && equalCheck.rotRole == null))
			return false;
		if (rotRole != null && !rotRole.equals(equalCheck.rotRole))
			return false;
		if ((rotTiers == null && equalCheck.rotTiers != null) || (rotTiers != null && equalCheck.rotTiers == null))
			return false;
		if (rotTiers != null && !rotTiers.equals(equalCheck.rotTiers))
			return false;
		return true;
	}
}
